package downloads;

import java.io.File;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Temporal;

/**
 * This class represents a download, which can be set up at a lecture page.
 * A download can be either a external Link, e.g. this download is located
 * on a different server. Or it can be internal, e.g. it was uploaded
 * using this application
 * @author Thorsten Ludwig
 */
@Entity
public class Download implements Serializable {
    
    /**
     * Name of the downloadlink
     */
    private String name;
    /**
     * filename of the downloadfile
     */
    private String filename;
    /**
     * Time, when the download was created
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date downloadDate;
    /**
     * File object for the uploaded file.
     * Note: not used when download is an external download
     */
    private File resource;
    /**
     * Determines wheter the download is located at this server or somewhere
     * else.
     */
    private boolean isExternalLink;
    /**
     * Link to the external download location 
     */
    private String externalLink;
    @Id
    @GeneratedValue
    private Long id;
    
    public Download() {
        this.downloadDate = new Date();
    }

    public Date getDownloadDate() {
        return downloadDate;
    }

    public String getExternalLink() {
        return externalLink;
    }

    public void setExternalLink(String externalLink) {
        this.externalLink = externalLink;
    }

    public boolean isIsExternalLink() {
        return isExternalLink;
    }

    public void setIsExternalLink(boolean isExternalLink) {
        this.isExternalLink = isExternalLink;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public File getResource() {
        return resource;
    }

    public void setResource(File resource) {
        this.resource = resource;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    
}
